package com.aididi.dto;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;

/**
 * @Auther: zx.xu
 * @Description:
 */

public class LogDto {
    /**
     * 查询类型
     */
    @Getter
    @Setter
    private String type;

    /**
     * //输入关键字
     */
    @Getter
    @Setter
    private String keyword;

    /**
     * 当前页
     */
    @Setter
    private Integer pageNum ;

    /**
     * 总条数
     */
    @Getter
    @Setter
    private Integer count;

    /**
     *     每页显示数量
     */
    private static final Integer DEFAULT_SIZE = 5;
    /**
     * 默认页
     */
    private static final Integer DEFAULT_PAGE = 1;

    /**
     * 获取页数
     * @return
     */
    public Integer getPage() {
        if(null == pageNum || pageNum ==0){
            return DEFAULT_PAGE;
        }
        if (count!=null&&pageNum>=count){
            pageNum=count;
        }
        return Math.max(DEFAULT_PAGE,pageNum);
    }

    public  Integer getDefaultSize() {
        return DEFAULT_SIZE;
    }

    @Override
    public String toString() {
        return "LogDto{" +
                "type='" + type + '\'' +
                ", keyword='" + keyword + '\'' +
                ", page=" + pageNum +
                '}';
    }
}
